package com.pfizer.pfizerExpertForPad;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;
/**
 * DiseaseDialog--<b>輸入病例碼介面</b>
 * 全屏顯示，無標題，為窗口化的activity
 * 樣式由佈局文件獲得
 * @author krui
 *@version 1.1 2011/11/23
 */
public class DiseaseDialog extends Activity implements OnClickListener {

	Context mContext;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);//設置無標題
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);//設置全屏
		setContentView(R.layout.diseasecodedialog);
		mContext = DiseaseDialog.this;
		View btnSend = findViewById(R.id.btnSend);
		View btnCancle = findViewById(R.id.btnCancle);
		btnSend.setOnClickListener(this);
		btnCancle.setOnClickListener(this);

	}
/**
 * 給需要的button綁定點擊事件處理
 * 
 */
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int Id = v.getId();
		switch (Id) {
		case R.id.btnSend:
			EditText et=(EditText)this.findViewById(R.id.etDiseaseCode);
			String sTmp=et.getText().toString().trim();
			if(sTmp.length()==0)
			{
				Toast.makeText(mContext, "請輸入病例碼！", Toast.LENGTH_SHORT).show();
				return;
			}
			pfizerApplication pApplication = (pfizerApplication) getApplicationContext();
			pApplication.setCaseCode(sTmp);
			((Activity) mContext).finish();
			Toast.makeText(mContext, "病例碼已經輸入！", Toast.LENGTH_SHORT).show();
			break;
		case R.id.btnCancle:
			((Activity) mContext).finish();
		default:
			break;
		}

	}

}
